package com.sardine.base.spring;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.util.StringUtils;

/**
 * ****************************************
 * Created by IntelliJ IDEA 14.1.12
 *	annotation 命名策略规则
 * @company:    北京京东世纪贸易有限公司
 * @description:    helloProfile
 * @author: daif
 * @version:    V1.0
 * @date:   2015/5/29 23:32
 * email:daifeng@jd.com
 * Copyright © 2015 JD Systems Incorporated. All rights reserved.
 * *****************************************
 */
public class BeanNamesGenerator implements BeanNameGenerator {

	private final String DAO_IMPLEMENTS_SUFFIX="Impl";
	@Override
	public String generateBeanName(BeanDefinition definition,
			BeanDefinitionRegistry registry) {
		String calssName=definition.getBeanClassName();
		calssName=calssName.substring(calssName.lastIndexOf(".")+1);
		calssName = StringUtils.uncapitalize(calssName);   
        calssName = calssName.replace(DAO_IMPLEMENTS_SUFFIX, "");
		return calssName;
	}

}
